

package com.hazelcast.internal.nearcache.impl;


import com.hazelcast.internal.serialization.Data;
import com.hazelcast.spi.impl.operationservice.Operation;

import javax.annotation.Nullable;

/**
 * Hook to be used by near cache invalidations or by statistics updates.
 * <p>
 * For instance, with this hook, you can implement needed
 * logic for truly invalidate/populate local near cache.
 */
public interface RemoteCallHook<K, V> {

    RemoteCallHook EMPTY_HOOK = new RemoteCallHook() {

        @Override
        public void beforeRemoteCall(Object key, Data keyData, Object value, Data valueData) {
        }

        @Override
        public void onRemoteCallSuccess(Operation remoteCall) {
        }

        @Override
        public void onRemoteCallFailure() {

        }
    };

    void beforeRemoteCall(K key, Data keyData, @Nullable V value, @Nullable Data valueData);

    void onRemoteCallSuccess(@Nullable Operation remoteCall);

    void onRemoteCallFailure();
}
